import java.util.ArrayList;

public class HMMProfile {
private ArrayList<HMMNode> NodeArray=new ArrayList<HMMNode>();
private int ProfileSize=0;
private String name=null;

public int GetProfileSize(){
	
	return ProfileSize;
}

public String GetProfileName(){
	
	return name;
}

public double GetMatchProbability(int NodeNo, int pos){
	HMMNode tmp= new HMMNode();
	tmp= NodeArray.get(NodeNo);
	return tmp.GetMatchProbability(pos);
}

public double GetInsertProbability(int NodeNo, int pos){
	HMMNode tmp= new HMMNode();
	tmp=NodeArray.get(NodeNo);
	return tmp.GetInsertProbability(pos);
}

public double GetTranProbability(int NodeNo, int pos){
	HMMNode tmp= new HMMNode();
	 tmp=NodeArray.get(NodeNo);
	return tmp.GetTranProbability(pos);
}



//read in a string to initialize one HMMER profile consists of specific number of HMMER nodes (component)
//It is upper level class's responsibility to make sure the string passed here are valid and complete 

public boolean SetHMMProfileName( String Name){

		int pos;
		char[] tmp= new char[100];
		String ProfileName;
		if (!Name.contains("NAME"))
			return false;
		else
			pos=Name.indexOf("NAME")+4;
			Name.getChars(pos, Name.length(),tmp, 0);
			ProfileName= new String(tmp);
			ProfileName=ProfileName.trim();
			name=ProfileName;
			return true;

}



public boolean SetHMMProfile( String S){
	
	String[] line=S.split("\r");
	for (int i=0;(i<line.length-2);i=i+3){
		String S_node=line[i]+"\r"+line[i+1]+"\r"+line[i+2];
		NodeArray.add(new HMMNode(S_node));
		ProfileSize+=1;
	}

	return true;
}

public boolean ResetHMMProfile(){
	
	 NodeArray.clear();
	 ProfileSize=0;
	 name=null;

	return true;
}
/*
public static void main (String[] args){
	
	double M_double,I_double,T_double;
	HMMProfile HMMprofile= new HMMProfile();
	String s1 = "COMPO   2.27165  4.34062  2.74969  2.66237  3.85083  2.68422  3.94348  3.25360  2.57389  2.81374  4.07419  3.19305  2.51331  2.98243  3.36374  2.95177  2.70552  2.63822  3.56042  3.77216 \r  2.68618  4.42225  2.77519  2.73123  3.46354  2.40513  3.72494  3.29354  2.67741  2.69355  4.24690  2.90347  2.73739  3.18146  2.89801  2.37887  2.77519  2.98518  4.58477  3.61503 0.0015 \r 6.88065  7.60300  0.61958  0.77255  0.00000        *";
	String s2 = "COMPO   2.27165  4.34062  2.74969  2.66237  3.85083  2.68422  3.94348  3.25360  2.57389  2.81374  4.07419  3.19305  2.51331  2.98243  3.36374  2.95177  2.70552  2.63822  3.56042  3.77216 \r  2.68618  4.42225  2.77519  2.73123  3.46354  2.40513  3.72494  3.29354  2.67741  2.69355  4.24690  2.90347  2.73739  3.18146  2.89801  2.37887  2.77519  2.98518  4.58477  3.61503 0.0015 \r 6.88065  7.60300  0.61958  0.77255  0.00000        *";
	String s3 = "COMPO   2.27165  4.34062  2.74969  2.66237  3.85083  2.68422  3.94348  3.25360  2.57389  2.81374  4.07419  3.19305  2.51331  2.98243  3.36374  2.95177  2.70552  2.63822  3.56042  3.77216 \r  2.68618  4.42225  2.77519  2.73123  3.46354  2.40513  3.72494  3.29354  2.67741  2.69355  4.24690  2.90347  2.73739  3.18146  2.89801  2.37887  2.77519  2.98518  4.58477  3.61503 0.0015 \r 6.88065  7.60300  0.61958  0.77255  0.00000        *";
	String s4 = "COMPO   2.27165  4.34062  2.74969  2.66237  3.85083  2.68422  3.94348  3.25360  2.57389  2.81374  4.07419  3.19305  2.51331  2.98243  3.36374  2.95177  2.70552  2.63822  3.56042  3.77216 \r  2.68618  4.42225  2.77519  2.73123  3.46354  2.40513  3.72494  3.29354  2.67741  2.69355  4.24690  2.90347  2.73739  3.18146  2.89801  2.37887  2.77519  2.98518  4.58477  3.61503 0.0015 \r 6.88065  7.60300  0.61958  0.77255  0.00000        *";
	String S_HMMProfile=s1+"\r"+s2+"\r"+s3+"\r"+s4;
	HMMprofile.SetHMMProfile(S_HMMProfile);
	I_double=HMMprofile.GetInsertProbability(1, 1);
	M_double=HMMprofile.GetMatchProbability(2, 2);
	T_double=HMMprofile.GetTranProbability(3, 3);
	
	
	System.out.printf("M_double：%f \r",M_double);
	System.out.printf("I_double：%f \r",I_double);
	System.out.printf("T_double：%f \r",T_double);
}


*/

}
